package org.libcsp.generic.util.office;

import cn.hutool.poi.excel.sax.handler.MapRowHandler;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ExcelUtil extends cn.hutool.poi.excel.ExcelUtil {
    public static List<List<String>> excel2List(int sheetIndex, int start, int end, InputStream stream) {
        List<List<String>> list = new ArrayList<>();
        readBySax(stream, sheetIndex, new MapRowHandler(0,start,end) {
            @Override
            public void handleData(int sheetIndex, long rowIndex, Map<String, Object> data) {
                list.add(data.values().stream().map(o->(String)o).toList());
            }
        });
        return list;
    }
}
